class Post implements Comparable {

    static searchable = {
        only: ['content', 'title']
        content spellCheck: "include"
        title spellCheck: "include"
    }

    String title = ""
    String content = ""
    String teaser = ""
    Date dateCreated = new Date()
    Date lastUpdated
    Date displayDate = new Date()
    SortedSet comments
    //PostCategory category
    long school = 0
    Author author
    long classesid = 0  // 班级id,如果这个post是学生发的话,这个id就是班级的,如果是教师发的
                                 // 那么班级的id为空,如果是班级的post,那么这个id就是班级自己的id
    boolean privce = false //定义此post是否为私有的，也就是家长看的，学生不能看到
    static hasMany = [comments: PostedComment]
    static belongsTo = [site: Site]


    static mapping = {
        content type: "text"
        teaser type: "text"
        cache true
        comments cache: 'nonstrict-read-write'
        author cache: 'nonstrict-read-write'
        category cache: 'nonstrict-read-write'
    }

    /**
     * Sort by date created descending
     */
    public int compareTo(Object obj) {
        return (obj.displayDate <=> displayDate)
    }

    String toString() {
        return "${title}"
    }

}
